Conditions | 9 |
Total Lines | 69 |
Code Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | const httpProcessor = require('../HttpProcessor'); |
||
35 | async handle(IdFilter) |
||
36 | { |
||
37 | if (! IdFilter.isSuccessful()) { |
||
38 | if (IdFilter.isWithImage()) { |
||
39 | this.getWithImage(IdFilter); |
||
40 | } else { |
||
41 | |||
42 | const idNumber = IdFilter.getIDNumber(); |
||
43 | const firstName = IdFilter.getFirstName(); |
||
44 | const lastName = IdFilter.getLastName(); |
||
45 | const phone = IdFilter.getPhoneNumber(); |
||
46 | |||
47 | if (IdFilter.getIDType() === constants.idValues.TYPE_BVN) { |
||
48 | const url = '/CredBvn/api/v1/Bvn/GetCustomerBvn'; |
||
49 | |||
50 | const body = { |
||
51 | 'bvn' : idNumber, |
||
52 | 'PhoneNumber' : phone |
||
53 | }; |
||
54 | |||
55 | return this.postData(IdFilter,body,url); |
||
56 | } |
||
57 | if (IdFilter.getIDType() === constants.idValues.TYPE_NIN) { |
||
58 | if (! IdFilter.isSuccessful()) { |
||
59 | const url = '/CredNin/api/v1/Identity?phoneNo=' + phone; |
||
60 | const body = {}; |
||
61 | |||
62 | return this.postData(IdFilter,body,url); |
||
63 | } |
||
64 | |||
65 | //If request is not successful makes post with IdNumber |
||
66 | if (! IdFilter.isSuccessful()) { |
||
67 | const url = '/CredNin/api/v1/IdentityByNin?nin=' + idNumber; |
||
68 | const body = {}; |
||
69 | |||
70 | return this.postData(IdFilter,body,url); |
||
71 | } |
||
72 | } |
||
73 | |||
74 | if (IdFilter.getIDType() === constants.idValues.TYPE_DRIVERS_LICENSE) { |
||
75 | const url = '/Verify/api/v1/FrscInfo'; |
||
76 | |||
77 | const body = { |
||
78 | 'firstname' : firstName, |
||
79 | 'lastname' : lastName, |
||
80 | 'phoneNo' : phone, |
||
81 | 'frscidentityNo' : idNumber |
||
82 | }; |
||
83 | return this.postData(IdFilter,body,url); |
||
84 | } |
||
85 | |||
86 | if (IdFilter.getIDType() === constants.idValues.TYPE_CUSTOMER_PROFILE) { |
||
87 | const url = '/CredBvn/api/v1/CustomerProfile'; |
||
88 | IdFilter.setCredequityProfile(); |
||
89 | const profile = IdFilter.getCredequityProfile(); |
||
90 | |||
91 | const body = { |
||
92 | "Nin" : profile['nin'], |
||
93 | "FrscNo" : profile['frscno'], |
||
94 | "phoneNo" : phone, |
||
95 | "Bvn" : profile['bvn'] |
||
96 | }; |
||
97 | |||
98 | return this.postData(IdFilter,body,url); |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | |||
103 | } |
||
104 | |||
164 | module.exports = Credequity; |